/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.entities;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.NamedStoredProcedureQueries;
import javax.persistence.NamedStoredProcedureQuery;
import javax.persistence.ParameterMode;
import javax.persistence.StoredProcedureParameter;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Tuan Long
 */
@Entity
@Table(name = "EventInfo")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "EventInfo.findAll", query = "SELECT e FROM EventInfo e"),
    @NamedQuery(name = "EventInfo.findById", query = "SELECT e FROM EventInfo e WHERE e.id = :id"),
    @NamedQuery(name = "EventInfo.findByAvatarImg", query = "SELECT e FROM EventInfo e WHERE e.avatarImg = :avatarImg"),
    @NamedQuery(name = "EventInfo.findByEventShortDesc", query = "SELECT e FROM EventInfo e WHERE e.eventShortDesc = :eventShortDesc"),
    @NamedQuery(name = "EventInfo.findByCreated", query = "SELECT e FROM EventInfo e WHERE e.created = :created")   
})
@NamedStoredProcedureQueries({
    @NamedStoredProcedureQuery(name="EventInfo.createNewEvent",procedureName = "sp_createNewEvent",parameters = {
       @StoredProcedureParameter(name="name",mode=ParameterMode.IN,type=String.class),
       @StoredProcedureParameter(name="des",mode=ParameterMode.IN,type=String.class),
       @StoredProcedureParameter(name="type",mode=ParameterMode.IN,type=String.class),
       @StoredProcedureParameter(name="timeS",mode=ParameterMode.IN,type=Date.class),
       @StoredProcedureParameter(name="timeE",mode=ParameterMode.IN,type=Date.class),
       @StoredProcedureParameter(name="avatar",mode=ParameterMode.IN,type=String.class),
       @StoredProcedureParameter(name="shortdes",mode=ParameterMode.IN,type=String.class),
       @StoredProcedureParameter(name="address",mode=ParameterMode.IN,type=String.class)
    }),
    @NamedStoredProcedureQuery(name="EventInfo.getEventInfoContentById",procedureName = "sp_getEventInfoContentById",parameters = {
       @StoredProcedureParameter(name="eventId",mode=ParameterMode.IN,type=Integer.class)       
    }),
    @NamedStoredProcedureQuery(name="EventInfo.updateEventByEventId",procedureName = "sp_updateEventByEventId",parameters = {
        @StoredProcedureParameter(name="eventId",mode=ParameterMode.IN,type=Integer.class),
       @StoredProcedureParameter(name="name",mode=ParameterMode.IN,type=String.class),
       @StoredProcedureParameter(name="des",mode=ParameterMode.IN,type=String.class),
       @StoredProcedureParameter(name="type",mode=ParameterMode.IN,type=String.class),
       @StoredProcedureParameter(name="timeS",mode=ParameterMode.IN,type=Date.class),
       @StoredProcedureParameter(name="timeE",mode=ParameterMode.IN,type=Date.class),
       @StoredProcedureParameter(name="avatar",mode=ParameterMode.IN,type=String.class),
       @StoredProcedureParameter(name="shortdes",mode=ParameterMode.IN,type=String.class),
       @StoredProcedureParameter(name="address",mode=ParameterMode.IN,type=String.class)
    })
})
public class EventInfo implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "Id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 200)
    @Column(name = "AvatarImg")
    private String avatarImg;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 200)
    @Column(name = "EventShortDesc")
    private String eventShortDesc;
    @Column(name = "Address")
    private String address;
    @Column(name = "Created")
    @Temporal(TemporalType.TIMESTAMP)
    private Date created;
    @JoinColumn(name = "EventId", referencedColumnName = "EventId")
    @ManyToOne(optional = false)
    private EventLibrary eventId;

    public EventInfo() {
    }

    public EventInfo(Integer id) {
        this.id = id;
    }

    public EventInfo(Integer id, String avatarImg, String eventShortDesc) {
        this.id = id;
        this.avatarImg = avatarImg;
        this.eventShortDesc = eventShortDesc;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getAvatarImg() {
        return avatarImg;
    }

    public void setAvatarImg(String avatarImg) {
        this.avatarImg = avatarImg;
    }

    public String getEventShortDesc() {
        return eventShortDesc;
    }

    public void setEventShortDesc(String eventShortDesc) {
        this.eventShortDesc = eventShortDesc;
    }

    public Date getCreated() {
        return created;
    }

    public void setCreated(Date created) {
        this.created = created;
    }

    public EventLibrary getEventId() {
        return eventId;
    }

    public void setEventId(EventLibrary eventId) {
        this.eventId = eventId;
    }
    
    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof EventInfo)) {
            return false;
        }
        EventInfo other = (EventInfo) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.entities.EventInfo[ id=" + id + " ]";
    }
    
}
